package chapter03.reg

import chisel3._

object RegEnable {
  def apply[T <: Data](next: T, enable: Bool): T = {
    val r = Reg(chiselTypeOf(next))
    when(enable) {
      r := next
    }
    r
  }

  def apply[T <: Data](next: T, init: T, enable: Bool): T = {
    val r = RegInit(init)
    when(enable) {
      r := next
    }
    r
  }
}
